package top.yueyazhui.order.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.yueyazhui.common.bean.Response;
import top.yueyazhui.order.service.OrderService;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @PostMapping("/add")
    public Response addOrder(@RequestParam("userId") String userId, @RequestParam("commodityCode") String commodityCode, @RequestParam("count") Integer count, @RequestParam("money") Double money) {
        if (orderService.addOrder(userId, commodityCode, count, money)) {
            return Response.success("下单成功");
        }
        return Response.error("下单失败");
    }
}
